#include "target.h"


target::target(light in_1, light in_2) {
	if (in_1.rect.center.x < in_2.rect.center.x)
	{
		left = in_1;
		right = in_2;
	}
	else
	{
		left = in_2;
		right = in_1;
	}

	center.x = (left.rect.center.x + right.rect.center.x) / 2;
	center.y = (left.rect.center.y + right.rect.center.y) / 2;

	delta_k = abs(left.slope_of_width - right.slope_of_width);

	dis_to_len_ratio = count_dis(center, left.rect.center) / left.rect_length;

	get_four_corner_point();
}

void target::get_four_corner_point(){
	Point2f temp[4];
	left.rect.points(temp);
	for (int i = 0; i < 4; i++)
	{
		if (temp[i].x > left.rect.center.x)
			continue;

		if (temp[i].y > left.rect.center.y)
			corner_point[3] = temp[i];
		else
			corner_point[0] = temp[i];
	}

	right.rect.points(temp);
	for (int i = 0; i < 4; i++)
	{
		if (temp[i].x < right.rect.center.x)
			continue;

		if (temp[i].y > right.rect.center.y)
			corner_point[2] = temp[i];
		else
			corner_point[1] = temp[i];
	}
}